package com.wedimob.slideshare;

import com.wedimob.slideshare.source.Source;
import com.wedimob.slideshare.task.ProgressObserver;
import com.wedimob.slideshare.task.disk.PathHelper;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {

        try {
            System.out.println("start ...");
            long begin = System.currentTimeMillis();

            SearchCriteria criteria = new SearchCriteria("android best practices",
                    SortBy.RELEVANCE, 0, 30);
            criteria.addSource(Source.SLIDESHARE);
            //criteria.addSource(Source.YOUTUBE);
            Search.searchDocuments(criteria, WriteType.ONDISK, new ProgressObserver(5));

            System.out.println("done in "
                    + (System.currentTimeMillis() - begin) / 1000 + " sec");
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        } finally {
            try {
                RuntimeConfig
                        .getInstance()
                        .getWriter()
                        .delete(PathHelper.buildTmpPath());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }

}
